#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include<QtGui/QMainWindow>
#include<QtCore/QModelIndex>
#include<QHash>
class QLabel;  //用于加速编译
class QListWidget;
class QHBoxLayout;
class QVBoxLayout;
class QTableWidget;
class QFileDialog;
class QSystemTrayIcon;
class decoder;
class QLCDNumber;
class ShowMusicInfo;
class SearchMp3Dialog;

namespace Phonon{
        class SeekSlider;
        class VolumeSlider;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
        enum PlayState {
                RANDOM = 1,
                SEQUENCY = 0
        }ThisPlayState;

        enum TITLES{
                TITLE = 0,
                ARTIST = 1,
                ALBUM = 2,
                GENRE = 3,
                TIME = 4,
                YEAR = 5,
                LOCATION = 6
        }THISTITLE;

protected:
        void closeEvent(QCloseEvent *);

signals:
        void CurrentSongChanged();
        void Encoding(QString);
        void MusicTableChanged();
public:
    MainWindow();
    void readSetting();

private slots:
    void moveToTrashSlot();
    void playActionControlSlot();
    void refreshHashSlot();
    void aboutSlot();
    void refreshMusicInfoSlot();
    void editTagSlot();
    void setEncodingSlot(QString);
    void setEncodingGBK();
    void setEncodingGB18030();
    void setEncodingUTF8();
    void setEncodingLatin1();
    void setEncodingBIG5();
    void tickSlot(qint64);
    void LCDto0();
    void showSongMessage();
    void setPlayActionToggled();
    void setPlayingSongSelectedSlot();
    void playControlSlot(bool);
    QString getCurrentSongPath();
    PlayState getPlayState();
    void setCurrentSongNumSlot(QModelIndex);
    void setPlayStateSlot(bool);
    void play();
    void pause();
    void playNextSong();
    void playPreviousSong();
    void selectTitleSlot();
    void titleChangedSlot(QStringList);
    void importFileSlot();
    void importDocumentSlot();
    void toolbarVisibleSlot(bool);
    void saveConfigSlot();
    void removeFromListSlot();

private:
    void createLCD();
    void createVolumeSlider();
    void createSeekSlider();
    void createMenus();
    void createActions();
    void createToolBars();
    void createStatusBar();
    void createList();
    void createLayout();
    void createContextMenu();
    void createTrayIcon();
    void createDecoder();
    QStringList& titlesOfList();
    void setTitlesOfList();

private:
    //GUI
    //File Memu
    QMenu *FileMenu;
    QAction *ImportFileAction;
    QAction *ImportDocumentAction;
    QAction *ExitAction;
    //Play Menu
    QMenu *PlayMenu;
    QAction *PlayAction;
    QAction *NextSongAction;
    QAction *PreviousSongAction;
    QAction *RandomPlayAction;
    //View Menu
    QMenu *ViewMenu;
    QAction *ShowToolbarAction;
    QAction *SelectTitleAction;
    //QAction *SimpleMode;
    //Help Menu
    QMenu *HelpMenu;
    QAction *AboutAction;

    QToolBar *PlayToolBar;
    QToolBar *SearchToolBar;
    QToolBar *MusicInfoToolBar;
    ShowMusicInfo *MusicInfo;
    Phonon::SeekSlider *MainSeekSlider;
    Phonon::VolumeSlider *MainVolumeSlider;
    QLCDNumber *LCD;
    //context menu
    QAction *RemoveFromListAction;
    QMenu *SelectEncodingMenu;
    QAction *SetEncodingGBKAction;
    QAction *SetEncodingGB18030Action;
    QAction *SetEncodingUTF8Action;
    QAction *SetEncodingLatin1Action;
    QAction *SetEncodingBIG5Action;
    QAction *EditTagAction;
    QAction *MoveToTrashAction;
    //StatusBar
    QLabel *ConclusionLabel;

    //SystemTrayIcon
    QSystemTrayIcon *TrayIcon;
    QMenu *TrayIconMenu;
    QAction *ShowMainWindowAction;

    QWidget *CentraWidget;

    QString MainWindowTitle;

    QTableWidget *MusicTable;

    QStringList TitlesOfList;

    QFileDialog *ImportFileDialog;

    QVBoxLayout *Layout;

    decoder *Decoder;

    qint64 CurrentSongNum;

    PlayState State;

    QList<unsigned int> ListHash;

    SearchMp3Dialog *SMD;
};

#endif // MAINWINDOW_H
